package com.database.mapper;


import com.database.character.Collect;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CollectMapper {

  //添加收藏
  @Insert("insert into collect(user_id, post_id) values (#{userId}, #{postId})")
  int addCollect(Collect collect);

  //取消收藏
  @Delete("delete from collect where post_id = #{postId}")
  int deleteCollectByPostId(Integer postId);

  //根据postId查询收藏
  @Select("select * from collect where post_id = #{postId}")
  Collect getCollectByPid(Integer postId);

  //根据userId查询收藏
  @Select("select * from collect where user_id = #{userId}")
  List<Collect> getCollectByUid(Integer userId);
}
